﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using ThresholdAssistant.DataContract.Result;
using ThresholdAssistant.WebAPI.Models;
using ThresholdAssistant.WebAPI.Service;

namespace ThresholdAssistant.WebAPI.Controllers
{
    /// <summary>
    /// 标签控制器
    /// </summary>
    [Route("api/tag")]
    public class TagController : BaseController
    {
        /// <summary>
        /// 标签服务
        /// </summary>
        public TagService TagService { get; set; }


        /// <summary>
        /// 获取标签类型列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-tagtype-list")]
        [AllowAnonymous]
        public async Task<ContractResult<IEnumerable<TagtypeData>>> GetTagtypeListAsync(GetTagListParam param)
        {
            return await TagService.GetTagtypeListAsync(param);
        }

        /// <summary>
        /// 新增标签类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("add-tagtype")]
        [AllowAnonymous]
        public async Task<ContractResult<long>> AddTagtypeAsync(AddTagtypeParam param)
        {
            return await TagService.AddTagtypeAsync(param);
        }

        /// <summary>
        /// 获取标签类型信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-tagtype-info")]
        public async Task<ContractResult<TagtypeData>> GetTagTypeInfoAsync(GetTagtypeInfoParam param)
        {
            return await TagService.GetTagTypeInfoAsync(param);
        }

        /// <summary>
        /// 删除标签类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("delete-tagtype")]
        [AllowAnonymous]
        public async Task<ContractResult> DeleteTagtypeAsync(DeleteTagtypeParam param)
        {
            return await TagService.DeleteTagtypeAsync(param);
        }

        /// <summary>
        /// 修改标签类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("update-tagtype")]
        [AllowAnonymous]
        public async Task<ContractResult> UpdateTagtypeAsync(UpdateTagtypeParam param)
        {
            return await TagService.UpdateTagtypeAsync(param);
        }

        /// <summary>
        /// 获取标签列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-tag-list")]
        [AllowAnonymous]
        public async Task<ContractResult<IEnumerable<TagData>>> GetTagListAsync(GetTagListParam param)
        {
            return await TagService.GetTagListAsync(param);
        }

        /// <summary>
        /// 新增标签
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("add-tag")]
        [AllowAnonymous]
        public async Task<ContractResult<long>> AddTagAsync(AddTagParam param)
        {
            return await TagService.AddTagAsync(param);
        }

        /// <summary>
        /// 获取标签信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-tag-info")]
        [AllowAnonymous]
        public async Task<ContractResult<TagData>> GetTagInfoAsync(GetTagInfoParam param)
        {
            return await TagService.GetTagInfoAsync(param);
        }

        /// <summary>
        /// 删除标签及其下的数据
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("delete-tag")]
        [AllowAnonymous]
        public async Task<ContractResult> DeleteTagAsync(DeleteTagParam param)
        {
            return await TagService.DeleteTagAsync(param);
        }

        /// <summary>
        /// 编辑标签
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("update-tag")]
        [AllowAnonymous]
        public async Task<ContractResult> UpdateTagAsync(UpdateTagParam param)
        {
            return await TagService.UpdateTagAsync(param);
        }

        /// <summary>
        /// 获取标签列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-tag-dtos")]
        [AllowAnonymous]
        public async Task<ContractResult<IEnumerable<object>>> GetTagDtoListAsync(GetTagListParam param)
        {
            return await TagService.GetTagDtoListAsync(param); 
        }      

    }
}